package com.modelbuilder.config;

import com.baidubce.qianfan.Qianfan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class QianfanConfig {

    @Value("${qianfan.ak:}")
    private String accessKey;

    @Value("${qianfan.sk:}")
    private String secretKey;

    @Bean
    public Qianfan qianfan() {
        if (accessKey == null || accessKey.isEmpty() || secretKey == null || secretKey.isEmpty()) {
            throw new IllegalStateException("Qianfan配置错误：accessKey和secretKey不能为空");
        }

        return new Qianfan(accessKey, secretKey);
    }
}